package cn.rui.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 封装返回结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable{
    private boolean flag;//执行结果，true为执行成功 false为执行失败
    private String message;//返回结果信息，主要用于页面提示信息
    private Object data;//返回数据

    public static Result getSuccess(String msg){
        return new Result (true,msg,null);
    }

    public static Result getSuccess(String msg,Object data){
        return new Result (true,msg,data);
    }

    public static Result getFailure(String msg){
        return new Result (false,msg,null);
    }

    public static Result getFailure(String msg,Object data){
        return new Result (false,msg,data);
    }
}
